package net.lab1024.sa.user.config;

import net.lab1024.sa.common.common.security.AbstractSecurityConfig;
import net.lab1024.sa.user.module.system.user.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.core.userdetails.UserDetails;

import javax.servlet.http.HttpServletRequest;
import java.util.function.BiFunction;

@Configuration
public class SecurityConfig extends AbstractSecurityConfig  {


    @Autowired
    private LoginService loginService;

    @Override
    protected BiFunction<String, HttpServletRequest, UserDetails> userFunction() {

        return (token, request) -> loginService.getLoginUserDetail(token, request);
    }

    @Override
    protected String[] getAuthenticatedUrlPatterns() {
        return new String[]{"/**"};
    }

    @Override
    protected String[] getNoNeedLoginUrl() {
        return new String[]{"/goods/query","/wechat/login","/wechat/register","/frontCategory/queryPage"};
    }


}
